﻿using System;
using System.IO;
using System.Text;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            DriveInfo[] driveInfo = DriveInfo.GetDrives();
            foreach (DriveInfo p in driveInfo)
            {
                if (p.IsReady)
                {
                    Console.WriteLine($"驱动器名称：{p.Name}");
                    Console.WriteLine($"驱动器可用空间量：{p.AvailableFreeSpace}");
                    Console.WriteLine($"驱动器文件格式：{p.DriveFormat}");
                    Console.WriteLine($"驱动器类型：{p.DriveType}");           
                    Console.WriteLine($"驱动器总大小：{p.TotalSize}");
                    Console.WriteLine();
                }
                DirectoryInfo directoryInfo = new DirectoryInfo("D:\\test.txt");
                directoryInfo.Create();
                directoryInfo.CreateSubdirectory("test.txt");

                using (FileStream fsWrite = new FileStream(@"D:\\test.txt", FileMode.OpenOrCreate, FileAccess.Write))
                {
                    string str = "温柔  善良  大方  美丽  放弃 ";
                    byte[] buffer = Encoding.UTF8.GetBytes(str);
                    fsWrite.Write(buffer, 0, buffer.Length);
                }
                Console.WriteLine("已存入");

                using (StreamWriter dd = new StreamWriter(@"D:\\test.txt", true))
                {
                    dd.Write("new rap new star");
                }
                Console.WriteLine("存入成功");


            }
        }
    }
}
